home *** CD-ROM | disk | FTP | other *** search
/ SoundMaker 2003 (Professional Edition) / SoundMaker 2003 - Professional Edition.iso / midi tool / midioxse.exe / DATA.1 / Breath2NRPN.js < prev    next >
Text File  |  1999-11-26  |  2KB  |  91 lines

  1. // MIDIOX Test
  2. // Copyright (c) 2000 by Jamie O'Connell
  3. //
  4. // This script is an example of doing JScript with MIDI-OX
  5. // It converts each single Breath controller event into 4 NRPN messages, that
  6. // control filters on Patches (XG instruments).
  7.  
  8. var mox;
  9. var str, strWrk;
  10. var n, ii, nInst;
  11. var bGo;
  12. var notesOn;
  13. var baseChan;
  14.  
  15. // Create object
  16. mox = WScript.CreateObject("MoxKart.MoxWire.1", "On_");  
  17.  
  18. n = mox.NumberInstances;
  19. if (n > 0)
  20.    nInst = 1;
  21.    if (mox.AttachInstance( nInst ) == 1)     
  22.       WScript.Echo( "Attached Instance: " + nInst.toString() );
  23. }
  24. else if (mox.LaunchInstance() == 1)
  25. {
  26.    nInst = 1;
  27.    if (mox.AttachInstance( nInst ) == 1)    
  28.       WScript.Echo( "Launched and Attached Instance: " + nInst.toString() );
  29.    else
  30.       WScript.Echo( "Launched but could not Attach Instance: " + nInst.toString() );
  31. }
  32. else
  33.    WScript.Echo( "Launch MIDI-OX Failed" );
  34.  
  35. n = mox.NumberInstances;
  36.  
  37. // *** Try out our MIDI Input loop
  38. notesOn  = 0;     // init
  39. baseChan = 0;   // init -- we expect channel 1
  40.  
  41. if (mox.IsAttached == 1)
  42. {
  43.    mox.DivertMidiInput = 1;
  44.    mox.FireMidiInput = 1;
  45.    
  46.    WScript.Echo( "Press OK to end MIDI translate Loop" );
  47.    
  48.    mox.FireMidiInput = 0;
  49.    mox.DivertMidiInput = 0;
  50. }
  51.  
  52. str    = null;
  53. strWrk = null;
  54. mox    = null;
  55.  
  56. // Exit Point
  57. //------------------------------------------
  58.  
  59. function On_MidiInput( ts, stat, chan, dat1, dat2)
  60. {
  61.    // We convert all breath control messages into 4 message NRPNS
  62.    var newStat, newChan;
  63.    var newDat1, newDat2;
  64.  
  65.    // Change dat1 test: 'breath' (02) to 'modulation' (01) if you don't 
  66.    // have a breath controller, but want to see how this works
  67.    if (stat == 0x0B0 && dat1 == 0x02) 
  68.    {
  69.     newStat = stat + chan
  70.     mox.OutputMidiMsg( newStat, 0x63, 0x01 ); // NRPN MSB -- on XG (GS?): Filter cutoff
  71.     mox.OutputMidiMsg( newStat, 0x62, 0x20 ); // NRPN LSB
  72.     mox.OutputMidiMsg( newStat, 0x06, dat2 ); // DataEntry MSB (value of breath CC)
  73.     mox.OutputMidiMsg( newStat, 0x26, 0x00 ); // dataEntry LSB (0 in this case)
  74.    }
  75.    else // other message
  76.    {
  77.       newStat = stat + chan; 
  78.     mox.OutputMidiMsg( newStat, dat1, dat2 );
  79.    }
  80. }    
  81.  
  82. //------------------------------------------
  83. // connection point sink for SysEx
  84.  
  85. function On_SysExInput( strSysEx )
  86. {
  87.    mox.SendSysExString( strSysEx );
  88. }
  89.  
  90.